<include file="Public/header"/>
<div class="row">
    <div class="col-md-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>菜单列表</h5>
                <div class="row">
                    <div class="col-sm-2 pull-right">
                        <a href="javascript:menu_add('添加菜单','<{:U('Menu/addMenu')}>',540,320);"
                           class="layui-btn layui-btn-small">添加菜单</a>
                    </div>
                </div>
            </div>
            <div class="ibox-content">
                <div class="table-responsive">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th>#</th>
                            <th style="text-align: left;">菜单名称</th>
                            <th>控制器名称</th>
                            <th>方法名称</th>
                            <th>菜单级别</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <volist name="menu" id="vo">
                            <tr>
                                <td><{$vo.id}></td>
                                <td style="text-align: left;">
                                    <if condition="$vo['level'] eq 0">
                                        ├─
                                    <else/>
                                        └─
                                </if><{$vo.title}>
                                </td>
                                <td><{$vo.controller}></td>
                                <td><{$vo.action}></td>
                                <td>
                                    <if condition="!$vo['pid']">
                                        一级菜单
                                        <else/>
                                        二级菜单
                                    </if>
                                </td>
                                <td>
                                    <a class="layui-btn layui-btn-mini"
                                       onclick="menu_add('添加子菜单','<{:U('Menu/addMenu',['pid'=>$vo[id]])}>',540,320)"><i
                                            class="layui-icon">
                                        &#xe608;</i>添加子菜单</a>
                                    <a class="layui-btn layui-btn-mini layui-btn-normal"
                                       onclick="menu_edit('编辑菜单','<{:U('Menu/editMenu',['id'=>$vo[id]])}>',540,320)"><i
                                            class="layui-icon">&#xe642;</i>编辑</a>
                                    <a class="layui-btn layui-btn-danger layui-btn-mini"
                                       onclick="menu_del(this,'<{$vo[id]}>')"><i
                                            class="layui-icon">&#xe640;</i>删除</a>
                                </td>
                            </tr>
                        </volist>
                        </tbody>
                    </table>
                </div>
                <div class="page"><{$page}></div>
            </div>
        </div>
    </div>
</div>
<include file="Public/footer"/>
<script>
    layui.use(['form','laydate','layer'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,laydate = layui.laydate;
    });
    //添加菜单
    function menu_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    //添加菜单
    function menu_edit(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    //添加菜单
    function menu_del(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    /*用户-删除*/
    function menu_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                url:"<{:U('Menu/delMenu')}>",
                type:'post',
                data:'id='+id,
                success:function(res){
                    if(res.status){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                    }
                }
            });
        });
    }
</script>
</body>
</html>